<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>用户订单列表</title>
    <!-- jquery -->
    <script type="text/javascript" th:src="@{/js/jquery.min.js}"></script>
    <!-- bootstrap -->
    <link rel="stylesheet" type="text/css" th:href="@{/bootstrap/css/bootstrap.min.css}"/>
    <script type="text/javascript" th:src="@{/bootstrap/js/bootstrap.min.js}"></script>
    <!-- layer -->
    <script type="text/javascript" th:src="@{/layer/layer.js}"></script>
    <!-- common.js -->
    <script type="text/javascript" th:src="@{/js/common.js}"></script>
</head>
<body>
<div class="panel panel-default">
    <div class="panel-heading">用户订单列表</div>
    <table class="table" id="orderlist">
        <tr>
            <td>商品名称</td>
            <td>收货地址</td>
            <td>商品数量</td>
            <td>商品单价</td>
            <td>订单的创建时间</td>
            <td>订单状态</td>
           <!-- <td>库存数量</td>-->
            <td>详情</td>
        </tr>
        <tr th:each="order : ${oderList}">
            <td th:text="${order.goodsName}"></td>
            <!--<td><img th:src="@{${order.goodsImg}}" width="100" height="100"/></td>-->
            <td th:text="${order.deliveryAddrId}"></td>
            <td th:text="${order.goodsCount}"></td>
            <td th:text="${order.goodsPrice}"></td>
            <td th:text="${#dates.format(order.createDate, 'yyyy-MM-dd HH:mm:ss')}" colspan="1"></td>
            <td >
                <span th:if="${order.status eq 0}">未支付</span>
                <span th:if="${order.status eq 1}">待发货</span>
                <span th:if="${order.status eq 2}">已发货</span>
                <span th:if="${order.status eq 3}">已收货</span>
                <span th:if="${order.status eq 4}">已退款</span>
                <span th:if="${order.status eq 5}">已完成</span>
            </td>
            <!--<td th:text="${goods.stockCount}"></td>-->
            <!--<td><a th:href="'/goods/toList/'+${goods.id}">详情</a></td>-->
            <td><a th:href="'/order/toDetail/'+${order.id}">详情</a></td>
<!--            <td><a th:href="'/order/toDetail/'+${goods.id}">详情</a></td>-->
        </tr>
    </table>


</div>

<!--<p th:text = "'用户: '+ ${user.nickname} + ' 登录成功'">hello </p>-->
<!--<button onclick="signOut()">退出登录</button>-->
<!--<button><a th:href="'/order/toDetail/'+${user.id}">我的订单</a></button>-->

</body>

<script>
    function getCookie(cname)
    {
        var name = cname + "=";
        var ca = document.cookie.split(';');
        for(var i=0; i<ca.length; i++)
        {
            var c = ca[i].trim();
            if (c.indexOf(name)==0) return c.substring(name.length,c.length);
        }
        return "";
    }

    function signOut() {

        var ticket = getCookie('userTicket');

        document.cookie="userTicket=null; expires=Thu, 18 Dec 1970 12:00:00 GMT; path=/";
        window.location.reload()

        $.ajax({
            url: "/signOut",
            type: "POST",
            data: {
                ticket: ticket
            },
            success: function (data) {
                layer.closeAll();
                if (data.code == 200) {
                    layer.msg("删除redis缓存成功");
                    window.location.href="/login";
                } else {
                    layer.msg("删除redis缓存失败");
                }
            },
            error: function () {
                layer.closeAll();
            }
        });
    }
</script>
</html>